﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace itChatAdmin
{
    public partial class Loading : Form
    {
        public Loading()
        {
            InitializeComponent();
        }

        private void Loading_Load(object sender, EventArgs e)
        {
            //获取uid,检查数据库，使用线程在后台处理
            Thread myThread = new Thread(new ThreadStart(CheckLoading));
            myThread.Start();
        }
        private void CheckLoading()
        {
            String OldMessage = "";
            while(Form1.Loading_OK==false)
            {
                if(OldMessage== Form1.Loading_Msg)
                {
                    Thread.Sleep(100);
                    continue;
                }
                else
                {
                    OldMessage = Form1.Loading_Msg;
                    this.Invoke((EventHandler)delegate
                    {
                        this.textBox1.AppendText(OldMessage+Environment.NewLine);
                    });
                }
            }
            this.Invoke(new Action(this.Close));
        }
    }
}
